const express = require('express');
const bodyParser = require('body-parser');
const path = require('path');
const app = express();
const axios = require("axios");
axios.defaults.baseURL = 'http://coding.gardel.top:8848/devoting';
const PORT = process.env.APP_PORT || 32148;
const HOST = process.env.APP_HOST || '0.0.0.0';
// const jsonwebtoken = require('jsonwebtoken')

const cookieParser = require('cookie-parser');
const session=require('express-session')
app.use(cookieParser());
//session
app.use(session({ 
    secret: 'keyboard cat',
    cookie: { maxAge: 60 * 1000 *30 *30 *24 },
    resave: false, //添加 resave 选项
    saveUninitialized: true,
}))
app.use('/static',express.static(path.join(__dirname,'./static')));

app.set("views", path.join(__dirname, "./views"));
app.set('view engine', 'html');
app.engine("html", require("express-art-template"));

app.use(express.urlencoded({ extended: false }));
app.use(express.json());

app.locals.users=[-1]
// session.token=[-1]
const admin = require('./router/admin');
const home = require('./router/home');
// 请求拦截
app.use('/admin',require('./middleware/loginGuard'))
app.use('/home',home);
app.use('/admin',admin);



app.listen(3500, ()=>{
    console.log("服务器开启");
})